package cn.itcast.manage;

import cn.itcast.bean.UmPassword;
import cn.itcast.dao.AddServlet;
import cn.itcast.dao.ListMessge;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/regServlet")
public class regServlet  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String user = req.getParameter("user");
        String password = req.getParameter("password");
        UmPassword u = new UmPassword();
        u.setUid(user);
        u.setPassword(password);
        System.out.println(u);
        AddServlet l = new AddServlet();
        l.regUm(u);
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write("注册成功");
        resp.setHeader("refresh","1;URL=/login.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
